package com.wanxi.dangdang.service.details;

import com.wanxi.dangdang.model.vo.CUserCheckVo;
import com.wanxi.dangdang.service.PermissionService;
import com.wanxi.dangdang.service.WeChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;


@Service("selfUserDetailsServiceImplC")
public class SelfUserDetailsServiceImplC implements UserDetailsService {

    @Autowired
    private WeChatService weChatService;


    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

        CUserCheckVo cUser = weChatService.checkAccount(username);
        if (ObjectUtils.isEmpty(cUser)) {
            throw new UsernameNotFoundException("根据用户名未找到用户信息");
        }
        return cUser;
    }
}
